<?php

namespace app\utils\ui\vue;

use app\utils\ui\ele\EleScript;
use app\utils\ui\native_element\Element;
use app\utils\ui\native_element\Root;

class SampleEleVue{

    /**
     * @var Root
     */
    public $root=null;

    /**
     * @param array|UIView $child 
     */
    public function __construct($child)
    {
        $this->root = new Root( new Element('div',true,[
            'id'=>'app'
        ],$child));
    }
    /**
     * @param array $handle 页面JS处理程序， key=>VueMethod, value=>JS CODE
     */
    public function response($other_data,$handle=[]){

        $html = $this->root->render(false);
        $html.= $this->root->script(new EleScript('#app',$this->root->data($other_data),$this->root->method(),$handle));
        return response($html);
    }
}